﻿@{
    var condtions = Model.Data["conditions"];
    var columns = Model.Data["columns"];
    var controller = Model.Data["controller"];
}
@@{
    ViewBag.Title = "@controller";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var Cols = new Jw.Models.sys_roleMenuColumnMapService().GetCurrentUserMenuColumns();
}

@@section scripts{
    <script src="~/Content/js/viewModel/com.viewModel.search.js"></script>
    <script type="text/javascript">
        var data = @@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model));
        var viewModel = function(){ 
            com.viewModel.search.apply(this,arguments);
        }
        ko.bindingViewModel(new viewModel(data));
    </script>
}

    @@Html.RenderToolbar()

    <div class="container_12" style="position:relative;">
    @for (var i = 0; i < condtions.Count; i++)
    {
        if (i % 3 == 0 && i>0)
        {
        @:
        <div class="clear"></div>
        @:
        }

        var item = condtions[i];
        var textPlugin = new List<string>() { "text", "autocomplete", "daterange" };
        var type = item.type.ToString();
        var cls = type == "text" ? "" : ("easyui-" + type);
        var val = textPlugin.Contains(type) ? "value" : (type + "Value");
        <div class="grid_1 lbl">@item.title</div>
        <div class="grid_2 val"><input type="text" data-bind="@val:form.@item.field" class="z-txt @cls" @Raw(item.options.ToString() == "" ? "" : "data-options=\"" + item.options + "\"")/></div>
    }

        @if (condtions.Count < 4)
        {
        <div class="clear"></div>
        
        <div class="grid_1 lbl">&nbsp;</div>
        <div class="grid_2 val">&nbsp;</div>
        
        }
        <div class="clear"></div>

        <div class="prefix_9" style="position:absolute;top:5px;height:0;">  
            <a id="a_search" href="#" class="button button-blue" data-bind="click:searchClick" style="margin:0 15px;">查询</a> 
            <a id="a_reset"  href="#" class="button button-blue" data-bind="click:clearClick">清空</a>
        </div>
    </div>
 
    <table data-bind="datagrid:grid">
            <thead>  
            <tr>  
            @foreach (var c in columns)
            {
                var hasFmt = c.formatter.ToString() != "";
                var hidden = c.Value<bool>("hidden");
                <th field="@c.field"    sortable="@c.sortable.ToString().ToLower()" align="@c.align"    width="@c.width" @Raw(hasFmt ? "formatter=\"" + c.formatter + "\"" : "")    @Raw(hidden ? "hidden=\"true\"" : "@Html.HideColumn(Cols,\"" + @c.field + "\")") >@c.title</th>
            }
            </tr>                            
        </thead>      
    </table>
 